/*******************************************************************
*
* main.c         : A small tiny programme made by zjz for caipiao.
* Create Date    : 20131216
* Author         : Zhangjinze
*
*******************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "caipiao.h"

/**
 * For some show.
 */
void showMessage(int MSG)
{
    switch (MSG)
    {
        case HELLOMESSAGE:
            printf("***************************************************************\n");
            printf("*This small tiny soft is made by Zhangjinze(799423351@qq.com).*\n");
            printf("*And COPYLEFT is beyound with it :)                           *\n");
            printf("***************************************************************\n");
            break;
        case FIRSTFUNCMESSAGE:
            printf("\n\n\n");
            system("cls");
            printf("*********************************************\n");
            printf("* 1. Update database file automatically.    *\n");
            printf("* 2. Update database file by hand.          *\n");
            printf("* 3. Search one stage number from database. *\n");
            printf("* 4. DO IT NOW!!!I WANT FIVE MILLION AWARD!!*\n");
            printf("* 0. exit.                                  *\n");
            printf("*********************************************\n");
            printf("Enter the number you want to do:");
            break;

    }
}

int testFunc()
{
    FilterLastStageNumber();
}

int main()
{
    U16 redN, blueN;
    int ret, ChooseN, OverFlag;
    char *AutoUpdateFile;

    OverFlag = 0;
    showMessage(HELLOMESSAGE);

    /**
     * First of all, generate groups of numbers
     */
    //GenerateAllGroup(33, 16);

    while(1) {
        showMessage(FIRSTFUNCMESSAGE);
        scanf("%d", &ChooseN);
        switch(ChooseN)
        {
            case AUTOUPDATEDATABASE:
                /**
               * Update lucky number automatically from
               * A file named caipiao.txt.
               */
                UpdateDatabaseAutomatically();
                break;
            case UPDATEDATABASEBYHAND:
                /**
               * Update lucky number by hand.
               */
                UpdateDatabaseHandly();
                break;
            case SEARCHASTAGE:
                GenerateHotColdNumber();
                break;
            case CACULATEBESTGROUPS:
                /**
               * Calculate..
               */
                CalculateBestGroups();
                break;
            case EXITFUNCTIONLIST:
                //GenerateHotColdNumber();
                GenerateHotColdNumber();
                printf("OK, bye.\n");
                OverFlag = 1;
                break;
            default:
                printf("You've entered invalid number, try again.\n");
                break;
        }

        if (OverFlag){
            OverFlag = 0;
            break;
        }
    }

    return 0;
}
